package com.eastmoney.emis.edda.task.report;

import com.eastmoney.emis.edda.infrastructure.report.ReportType;
import com.eastmoney.emis.edda.task.TaskManagement;
import com.eastmoney.emis.logger.LoggerFactory;
import org.slf4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.time.LocalDate;

@Component
@Async("eddaTaskExecutor")
public class ReportTaskProducer {

    private static final Logger log = LoggerFactory.getLogger(ReportTaskProducer.class);

    @Autowired
    private TaskManagement taskManagement;


    @Scheduled(cron = "${emis.edda.task.report-cron:0 */10 5-6 * * ?}")
    public void requestDDAReport() {
        LocalDate reportDate = LocalDate.now().minusDays(1);
        taskManagement.addTask(new ReportTask(ReportType.DDAReport, reportDate));
        taskManagement.addTask(new ReportTask(ReportType.DDIReport, reportDate));

    }


}
